package com.anolesoft.yr.mbus.prod.model.mapper;

import com.anolesoft.yr.mbus.prod.model.dto.ProdServiceDeleteDTO;
import com.anolesoft.yr.mbus.prod.model.dto.ProdServiceSaveDTO;
import com.anolesoft.yr.mbus.prod.model.dto.ProdServiceUpdateDTO;
import com.anolesoft.yr.mbus.prod.model.sql.ProdServiceSQL;
import com.anolesoft.yr.mbus.prod.model.vo.ProdServiceQueryVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProdServiceMapper {

    //根据主键查询产品服务项数据
    @Select(ProdServiceSQL.QUERY_PROD_SERVICE_BY_UID)
    @Results(id = "queryProdServiceByUid", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "prod_base_service_uid", property = "prodBaseServiceUid"),
            @Result(column = "service_code", property = "updateServiceCode"),
            @Result(column = "service_name", property = "updateServiceName"),
            @Result(column = "import_type", property = "updateImportType"),
            @Result(column = "is_timeliness", property = "updateIsTimeliness"),
            @Result(column = "remark", property = "updateRemark"),
            @Result(column = "objuid", property = "updateObjuid")
    })
    List<ProdServiceQueryVO> queryProdServiceByUid(String uid);

    //根据主键查询产品服务项唯一数据
    @Select(ProdServiceSQL.QUERY_PROD_SERVICE_BY_UID2)
    @Results(id = "queryProdServiceByUid2", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "service_code", property = "updateServiceCode"),
            @Result(column = "service_name", property = "updateServiceName"),
            @Result(column = "import_type", property = "updateImportType"),
            @Result(column = "is_timeliness", property = "updateIsTimeliness"),
            @Result(column = "remark", property = "updateRemark")
    })
    ProdServiceQueryVO queryProdServiceByUid2(String uid);

    //删除产品服务项信息
    @Update(ProdServiceSQL.DELETE_PROD_SERVICE)
    int deleteProdService(String objuid);

    //新增产品服务项信息表
    @Insert(ProdServiceSQL.SAVE_PROD_SERVICE)
    int saveProdService(ProdServiceSaveDTO prodServiceSaveDTO);

    //修改产品务项信息表
    @Update(ProdServiceSQL.UPDATE_PROD_SERVICE)
    int updateProdService(ProdServiceUpdateDTO prodServiceUpdateDTO);

    //删除产品服务项信息表
    @Update(ProdServiceSQL.DELETE_PROD_SERVICE2)
    int deleteProdService2(@Param("prodProductionUid") String prodProductionUid, @Param("prodServiceDeleteDTOList") List<ProdServiceDeleteDTO>  prodServiceDeleteDTOList);

    //根据主键查询产品服务项名称
    @Select(ProdServiceSQL.QUERY_PROD_SERVICE_NAME_BY_UID)
    @Results(id = "queryProdServiceNameByUid", value = {
            @Result(column = "objuid", property = "value"),
            @Result(column = "service_name", property = "text")
    })
    List<ProdServiceQueryVO> queryProdServiceNameByUid(String uid);

    //根据主键查询产品服务项唯一数据
    @Select(ProdServiceSQL.QUERY_PROD_SERVICE_BY_UID3)
    @Results(id = "queryProdServiceByUid3", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "service_code", property = "updateServiceCode"),
            @Result(column = "service_name", property = "updateServiceName"),
            @Result(column = "import_type", property = "updateImportType"),
            @Result(column = "is_timeliness", property = "updateIsTimeliness"),
            @Result(column = "remark", property = "updateRemark")
    })
    ProdServiceQueryVO queryProdServiceByUid3(String uid);

    //查询产品服务项名称
    @Select(ProdServiceSQL.QUERY_PROD_SERVICE_NAME)
    @Results(id = "queryProdServiceName", value = {
            @Result(column = "objuid", property = "objuid"),
            @Result(column = "service_name", property = "serviceName")
    })
    List<ProdServiceQueryVO> queryProdServiceName2(String prodName);

}
